'''
@Time    : 2022/3/24 15:51
@Author  : Fu Junyu
@Site    : www.fujunyu.cn
@File    : decoder.py
@Software: PyCharm
'''
import torch
import torch.nn.functional as F


class occupationDict():
    def __init__(self):
        super(occupationDict, self).__init__()

        self.occupationdict = {
            'artist': 0.0,
            'doctor': 1.0,
            'educator': 2.0,
            'engineer': 3.0,
            'entertainment': 4.0,
            'executive': 5.0,
            'healthcare': 6.0,
            'homemaker': 7.0,
            'lawyer': 8.0,
            'librarian': 9.0,
            'marketing': 10.0,
            'none': 11.0,
            'other': 12.0,
            'programmer': 13.0,
            'retired': 14.0,
            'salesman': 15.0,
            'scientist': 16.0,
            'student': 17.0,
            'technician': 18.0,
            'writer': 19.0,
            'administrator': 20.0
        }

    @property
    def Dict(self):
        return self.occupationdict

class occupationDictTest():
    def __init__(self):
        super(occupationDictTest, self).__init__()

        self.occupationdict = {
            'artist': 0,
            'doctor': 1,
            'educator': 2,
            'engineer': 3,
            'entertainment': 4,
            'executive': 5,
            'healthcare': 6,
            'homemaker': 7,
            'lawyer': 8,
            'librarian': 9,
            'marketing': 10,
            'none': 11,
            'other': 12,
            'programmer': 13,
            'retired': 14,
            'salesman': 15,
            'scientist': 16,
            'student': 17,
            'technician': 18,
            'writer': 19,
            'administrator': 20
        }

    @property
    def Dict(self):
        return self.occupationdict

class movieTypeDict_ML_1M():
    def __init__(self):
        super(movieTypeDict_ML_1M, self).__init__()
        self.typeDict = {
            'Action': F.one_hot(torch.tensor([0]), 18).view(18).numpy().tolist(),
            'Adventure': F.one_hot(torch.tensor([1]), 18).view(18).numpy().tolist(),
            'Animation': F.one_hot(torch.tensor([2]), 18).view(18).numpy().tolist(),
            'Children\'s': F.one_hot(torch.tensor([3]), 18).view(18).numpy().tolist(),
            'Comedy': F.one_hot(torch.tensor([4]), 18).view(18).numpy().tolist(),
            'Crime': F.one_hot(torch.tensor([5]), 18).view(18).numpy().tolist(),
            'Documentary': F.one_hot(torch.tensor([6]), 18).view(18).numpy().tolist(),
            'Drama': F.one_hot(torch.tensor([7]), 18).view(18).numpy().tolist(),
            'Fantasy': F.one_hot(torch.tensor([8]), 18).view(18).numpy().tolist(),
            'Film-Noir': F.one_hot(torch.tensor([9]), 18).view(18).numpy().tolist(),
            'Horror': F.one_hot(torch.tensor([10]), 18).view(18).numpy().tolist(),
            'Musical': F.one_hot(torch.tensor([11]), 18).view(18).numpy().tolist(),
            'Mystery': F.one_hot(torch.tensor([12]), 18).view(18).numpy().tolist(),
            'Romance': F.one_hot(torch.tensor([13]), 18).view(18).numpy().tolist(),
            'Sci-Fi': F.one_hot(torch.tensor([14]), 18).view(18).numpy().tolist(),
            'Thriller': F.one_hot(torch.tensor([15]), 18).view(18).numpy().tolist(),
            'War': F.one_hot(torch.tensor([16]), 18).view(18).numpy().tolist(),
            'Western': F.one_hot(torch.tensor([17]), 18).view(18).numpy().tolist()
        }

    @property
    def Dict(self):
        return self.typeDict




